All Projects → Anderson-Lu → gotask

Anderson-Lu / gotask

Licence: MIT License
A high performance concurrent task manager.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gotask

obsidian-tasks
Task management for the Obsidian knowledge base.
Stars: ✭ 648 (+3140%)
Mutual labels:  task-manager
scheduler
Task Scheduler for Laravel applications. UI from scratch
Stars: ✭ 18 (-10%)
Mutual labels:  task-manager
celery.node
Celery task queue client/worker for nodejs
Stars: ✭ 164 (+720%)
Mutual labels:  task-manager
PySiQ
A Python Simple Queue system for your apps
Stars: ✭ 23 (+15%)
Mutual labels:  task-manager
electrocute
See all electron-based applicatios that you have running
Stars: ✭ 13 (-35%)
Mutual labels:  task-manager
gitlab task manager
Microsoft Todo inspired task manager leveraging Gitlab's Issue Tracker as the backend
Stars: ✭ 22 (+10%)
Mutual labels:  task-manager
slated-obsidian
Task management in Obsidian.md
Stars: ✭ 123 (+515%)
Mutual labels:  task-manager
FirefoxTaskMonitor
Show CPU & memory bar, per tab and all tasks. Firefox userChrome script. 🛠️📊
Stars: ✭ 16 (-20%)
Mutual labels:  task-manager
bikeshed
Lock free hierarchical work scheduler
Stars: ✭ 78 (+290%)
Mutual labels:  task-manager
reflow
A light-weight lock-free series/parallel combined scheduling framework for tasks. The goal is to maximize parallelism in order to minimize the execution time overall.
Stars: ✭ 23 (+15%)
Mutual labels:  task-manager
Taskly
Flutter app to manage tasks.
Stars: ✭ 126 (+530%)
Mutual labels:  task-manager
taska
Workflow Management for Biomedical exploration
Stars: ✭ 29 (+45%)
Mutual labels:  task-manager
WeekToDoWeb
WeekToDo is a free minimalist weekly planner app focused on privacy. Schedule your tasks and projects with to do lists and a calendar. Available for Windows, Mac, Linux or online.
Stars: ✭ 48 (+140%)
Mutual labels:  task-manager
gronx
Lightweight, fast and dependency-free Cron expression parser (due checker), task scheduler and/or daemon for Golang (tested on v1.13 and above) and standalone usage
Stars: ✭ 206 (+930%)
Mutual labels:  task-manager
unfog.vim
⏱ Vim plugin for Unfog CLI task & time manager.
Stars: ✭ 61 (+205%)
Mutual labels:  task-manager
solid-focus
Solid Task Manager
Stars: ✭ 48 (+140%)
Mutual labels:  task-manager
ManagedShell
A library for creating Windows shell replacements using .NET.
Stars: ✭ 134 (+570%)
Mutual labels:  task-manager
Task
No description or website provided.
Stars: ✭ 14 (-30%)
Mutual labels:  task-manager
stack-public
A key-value based writer.
Stars: ✭ 19 (-5%)
Mutual labels:  task-manager
routinger
Routinger is a task scheduler app that is made to make you a better person at no extra cost. The code is open-source. Dart language and Flutter framework are used extensively.
Stars: ✭ 14 (-30%)
Mutual labels:  task-manager

Chinese Document

Gotask is a concurrent task scheduling tool based on waitegroup. Concurrent task solution for concurrent execution of computation and consistency of result data

Dependency

go get github.com/Anderson-Lu/gotask

Quick Start

Create a new task manager like this:

var tasks = NewGoTask(500, false)

here,500 is the largest concurrent number for taksManager. if quickMode is set to true, specifc task will be executed immediately when task.AddTask() method is invoked.

Defined a function witch will be excuted concurrently. Note that all parameters is ...interface{} and use tasks.GetParamter to get concrete parameter.

var total = 0
func add(params ...interface{}) {
	time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
	lock.Lock()
	total += tasks.GetParamter(0, params).(int)
	lock.Unlock()
}

Regist concret task to manager.

for i := 0; i < 10000; i++ {
	tasks.Add(add, 1)
}
tasks.Start() 

if tasks.Start() is invoked, main routine will be blocked and wait to all subTask finish.

Sample Demo

Cyclic 10000 cumulative calculation

var tasks = NewGoTask(10000, false)
var lock sync.Mutex
var total = 0

func add(params ...interface{}) {
	time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
	lock.Lock()
	total += tasks.GetParamter(0, params).(int)
	lock.Unlock()
}

func Demo() {
	for i := 0; i < 10000; i++ {
		tasks.Add(add, 1)
	}
	t.StartTimer()
	tasks.Start()
}

API Intro

//Create concurrent task manager instance
NewGoTask(maxConcurentNum int, quickMode bool) *GoTask 

//Add subtask
Add(task func(...interface{}), params ...interface{})

//Get specific params with index
GetParamter(index int, params interface{}) interface{} 

//Start all subTasks concurrently
Start()

//Return how much time cost for all subtasks
Cost() int

//Finsh all tasks manually and is required if quickmode = true
Done()

Performance

we assume that we add numbers in concurrent way. Everytime we add 1 and loop 10000 times.

conccurent_num    loop_time     cost/op            bytes/op       allocs/op         total_time  avg_time
--------------------------------------------------------------------------------------------------------
100               1             7816076500 ns/op   2476760 B/op   40396 allocs/op   7.82s       7.82s
500               1             1576902314 ns/op   2669496 B/op   41186 allocs/op   1.528s      1.528s
1000              2             791744067 ns/op    1668632 B/op   30433 allocs/op   2.420s      1.21s
10000             300000        3564 ns/op         37 B/op        0 allocs/op       7.841s      0.0000261s

There are some reasons that makes gotask is slower then original goroutine:

  • In my last commit, I add a time split duration(50ms) between each task
for {
	if self.curTaskNum < self.max {
		break
	}
	// time.Sleep(time.Millisecond * 50) //now I delete this row 
}
  • If you want to make your concurrent tasks faster, you can set quickMode=true like this var tasks = NewGoTask(10000, true)

  • For some cases, if your params is concrete, I recommend that you use specific gorutine instead of use gotask because this can avoid multiple type convertion. But if your tasks is different(like three tasks,taskA,taskB and taskC) so that you can use gotask because it make your code more elegant and easy-maintained. The demos in gotask_test.go is sample and all tasks is the same, so that you can use original gorutine instead of gotask.

So what make Gotask slower?

  • params type convert
  • external manager cost
  • all tasks are closure method

So when to use Gotask?

  • multiple tasks is different.
  • gorutine number limitation expecially in some spider cases, large gorutine number will make your machine broking.
  • you need to stat all your tasks and so on.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].