mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
* ttables: smaller table, 5x speedup * thavlak: less iterations, less loops; 30% speedup * tasyncclosestall: shorter timeout; 35% speedup * gcleak4: less iterations, 2x speedup * ttimes: remove deprecated stuff * tdangerisrelease: remove cpp backend, 3x speedup * tfrexp1: smaller range, 2x speedup * trtree: fix warnings, less iterations, 6x speedup * tasyncawait_cyclebreaker: smaller swarm size; 2x speedup * trealloc: smaller number of iterations; 10x speedup * towned_binary_tree: less iterations, 4x speedup * tclosure: remove unused code, less iterations; 2x speedup * twaitany: less durations; 1.4x speedup * tasync_misc: less iterations, 2x speedup * t8535: smaller sleep, 1.5x speedup * tmanyjoin: smaller sleep, 2x speedup * t12221: shorter sleeps, removed two slower tests; 1.6x speedup * tfuturestream: smaller sleep; 1.5x speedup * growobjcrash: less iterations; 2x speedup * ttryrecv: smaller sleep; 1.5x speedup * treusetvar: less threads; 2x speedup * delete tthreadanalysis2, basically a duplicate of tthreadanalysis * t7758: less iterations, 1.5x speedup * tasyncawait: smaller swarm, less messages; 1.5x speedup * tjsandnativeasync: smaller sleep, 1.5x speedup * tpendingcheck: smaller sleep, 1.5x speedup * remove rodfiles test category * move tseq from its own category to 'collections' category * remove unneeded tests and helpers from 'assert' category * stdlib: merge tbitops2 into tbitops * remove 'trepr2' from 'stdlib' cat * merge 'tstreams' into one file * remove 'tinefficient_const_table' from 'ccbugs' cat * merge 'tcollections_to_string' into 'tcollections' * tblocking_channel: smaller sleep, small speedup * tconvexhull: less iterartions; 1.2x speedup * merge 'tdeepcopy2' into 'tdeepcopy' * merge 'tdisjoint_slice2' into 'tdisjoint_slice1' * tmissing_deepcopy: smaller sequence * tsendtwice: smaller arrays; 5x speedup * remove 'tindexerrorformatbounds' * disable multimethod tests * remove 'gc:none' and 'refc' without 'd:useRealtimeGC' from gc tests * koch.nim: bootstrap just with '-d:release', no need for 'csource' * add github workflow for documentation * testament: no need for 8 sub-second decimals
73 lines
1.6 KiB
Nim
73 lines
1.6 KiB
Nim
discard """
|
|
output: '''ob2 @[]
|
|
ob @[]
|
|
ob3 @[]
|
|
3
|
|
ob2 @[]
|
|
ob @[]
|
|
ob3 @[]
|
|
'''
|
|
cmd: "nim c -r --threads:on $file"
|
|
"""
|
|
|
|
# bug #4776
|
|
|
|
import tables
|
|
|
|
type
|
|
Base* = ref object of RootObj
|
|
someSeq: seq[int]
|
|
baseData: array[40000, byte]
|
|
Derived* = ref object of Base
|
|
data: array[40000, byte]
|
|
|
|
type
|
|
ThreadPool = ref object
|
|
threads: seq[ptr Thread[ThreadArg]]
|
|
channels: seq[ThreadArg]
|
|
TableChannel = Channel[TableRef[string, Base]]
|
|
ThreadArg = ptr TableChannel
|
|
|
|
var globalTable {.threadvar.}: TableRef[string, Base]
|
|
globalTable = newTable[string, Base]()
|
|
let d = new(Derived)
|
|
globalTable.add("ob", d)
|
|
globalTable.add("ob2", d)
|
|
globalTable.add("ob3", d)
|
|
|
|
proc testThread(channel: ptr TableChannel) {.thread.} =
|
|
globalTable = channel[].recv()
|
|
for k, v in pairs globaltable:
|
|
echo k, " ", v.someSeq
|
|
var myObj: Base
|
|
deepCopy(myObj, globalTable["ob"])
|
|
myObj.someSeq = newSeq[int](100)
|
|
let table = channel[].recv() # same table
|
|
echo table.len
|
|
for k, v in mpairs table:
|
|
echo k, " ", v.someSeq
|
|
assert(table.contains("ob")) # fails!
|
|
assert(table.contains("ob2")) # fails!
|
|
assert(table.contains("ob3")) # fails!
|
|
|
|
var channel: TableChannel
|
|
|
|
proc newThreadPool(threadCount: int) = #: ThreadPool =
|
|
#new(result)
|
|
#result.threads = newSeq[ptr Thread[ThreadArg]](threadCount)
|
|
#var channel = cast[ptr TableChannel](allocShared0(sizeof(TableChannel)))
|
|
channel.open()
|
|
channel.send(globalTable)
|
|
channel.send(globalTable)
|
|
#createThread(threadPtr[], testThread, addr channel)
|
|
testThread(addr channel)
|
|
#result.threads[i] = threadPtr
|
|
|
|
proc stop(p: ThreadPool) =
|
|
for t in p.threads:
|
|
joinThread(t[])
|
|
dealloc(t)
|
|
|
|
|
|
newThreadPool(1)#.stop()
|