Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search slow after time.sleep #2646

Closed
1 task done
safehumeng opened this issue Jan 5, 2023 · 3 comments
Closed
1 task done

search slow after time.sleep #2646

safehumeng opened this issue Jan 5, 2023 · 3 comments

Comments

@safehumeng
Copy link

safehumeng commented Jan 5, 2023

Platform

OS: Ubuntu 18.04.6 LTS

Faiss version: 1.5.3

Installed from: pip install faiss

Running on:

  • unknown

Interface:

  • Python

build index:
index = faiss.index_factory(self.d, "IDMap,Flat", faiss.METRIC_INNER_PRODUCT)
save index:
faiss.write_index(index, index_path)
read_index:
faiss_index = faiss.read_index(index_path)

loop 100, if "time.sleep(0.2)", some step cost time > 20ms
if no "time.sleep(0.2)", all step cost time is steady

#1
for i in range(0, 100):
time.sleep(0.2)
s_time = time.time()
D, I = faiss_index.search(feature, 10)
print(time.time() - s_time)

time(s):
0.033809662
0.001636744
0.001227379
0.000584841
0.000673294
0.001588345
0.000566244
0.025577307
0.000347614
0.000542164
0.00073719
0.000379801
0.000360966
0.000362158
0.000305891
0.000477791
0.000341892
0.000299692
0.027928352
0.000314474
0.000792265
0.000283957
0.000373125
0.000294924
0.000402451
0.000293255
0.000303745
0.000368595
0.000586987
0.0218997
0.000355959
0.000353813
0.000363588
0.000471115
0.000345945
0.00036335
0.000501871
0.000407934
0.000304461
0.025905132
0.000546932
0.000391483
0.000262737
0.000678778
0.000277281
0.000338316
0.000325441
0.000415325
0.000396729
0.000430822
0.025371552
0.000266314
0.000350237
0.000250816
0.000309944
0.000453234
0.000368357
0.000521183
0.000347614
0.000543833
0.000417709
0.051602125
0.000535011
0.00065589
0.00056839
0.000513554
0.000328541
0.000306129
0.00067091
0.00054121
0.00051856
0.00036788
0.02731204
0.000954151
0.00055337
0.000694036
0.000400543
0.000449419
0.00043416
0.000398636
0.000354052
0.000365257
0.033364534
0.000450373
0.000359058
0.004323483
0.000331402
0.000561714
0.000916481
0.000369787
0.000481844
0.000393391
0.000357866
0.025733948
0.000584841
0.000360727
0.000318527
0.000590801
0.000495434
0.000266552

#2
for i in range(0, 100):
#time.sleep(0.2)
s_time = time.time()
D, I = faiss_index.search(feature, 10)
print(time.time() - s_time)

time(s):
0.046122789
0.000362396
0.00031805
0.000313759
0.000325203
0.00032568
0.000318527
0.000315666
0.000306606
0.000331163
0.000328302
0.000318289
0.000317335
0.000319004
0.00031662
0.00031805
0.000314713
0.000321388
0.000338554
0.000316143
0.000310659
0.000306129
0.000330448
0.000365973
0.000255823
0.000335455
0.00032115
0.000276089
0.000339508
0.000310898
0.000317812
0.00032568
0.000333309
0.00030756
0.000320435
0.000317812
0.00032258
0.000314236
0.000326872
0.000309706
0.000336885
0.000307322
0.000322104
0.00032711
0.00032711
0.000305414
0.000321388
0.000312805
0.000305891
0.00031805
0.000324965
0.00030899
0.000313282
0.000323772
0.000318527
0.000325918
0.000321627
0.000317097
0.000327587
0.000323296
0.000310898
0.000326872
0.000333548
0.000359297
0.000272274
0.000305414
0.000329018
0.000317335
0.000315666
0.000325441
0.00031662
0.000314474
0.00033021
0.000314951
0.000320911
0.00033021
0.000313282
0.000319958
0.000318289
0.000332832
0.000331879
0.000303507
0.000319242
0.000331879
0.000316381
0.000310659
0.000353813
0.000301838
0.000322819
0.00031662
0.000310183
0.000318766
0.000341415
0.000312328
0.00033021
0.000317335
0.000331402
0.000324726
0.000315905
0.000311375

@mdouze
Copy link
Contributor

mdouze commented Jan 9, 2023

I don't understand.

@safehumeng
Copy link
Author

I don't understand.

"faiss_index.search" Loop 100 times but each run time is not stable
normal:1ms
some step >20ms

@mdouze
Copy link
Contributor

mdouze commented Jan 24, 2023

please install with anaconda.

@mdouze mdouze closed this as completed Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants